 package tools.packet;

 import client.MapleCharacter;
 import handling.opcode.SendPacketOpcode;
 import handling.world.WorldAllianceService;
 import handling.world.WorldGuildService;
 import handling.world.guild.MapleGuild;
 import handling.world.guild.MapleGuildAlliance;
 import handling.world.messenger.MessengerRankingWorker;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import tools.DateUtil;
 import tools.data.output.MaplePacketLittleEndianWriter;








 public class MessengerPacket
 {
/*  24 */   private static final Logger log = LogManager.getLogger(MessengerPacket.class);




   public static byte[] addMessengerPlayer(String from, MapleCharacter chr, int position, int channel) {
/*  30 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/*  31 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  33 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/*  34 */     mplew.write(0);
/*  35 */     mplew.write(position);
/*  36 */     PacketHelper.addCharLook(mplew, chr, true, chr.isZeroSecondLook());
/*  37 */     mplew.writeMapleAsciiString(from);
/*  38 */     mplew.write(channel);
/*  39 */     mplew.write(position);
/*  40 */     chr.writeJobData(mplew);

/*  42 */     return mplew.getPacket();
   }





   public static byte[] joinMessenger(int position) {
/*  50 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/*  51 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  53 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/*  54 */     mplew.write(1);
/*  55 */     mplew.write(position);

/*  57 */     return mplew.getPacket();
   }





   public static byte[] removeMessengerPlayer(int position) {
/*  65 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/*  66 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  68 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/*  69 */     mplew.write(2);
/*  70 */     mplew.write(position);

/*  72 */     return mplew.getPacket();
   }




   public static byte[] messengerInvite(String from, int messengerId, int channel) {
/*  79 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/*  80 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  82 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/*  83 */     mplew.write(3);
/*  84 */     mplew.writeMapleAsciiString(from);
/*  85 */     mplew.write(channel);
/*  86 */     mplew.writeInt(messengerId);
/*  87 */     mplew.write(0);

/*  89 */     return mplew.getPacket();
   }




   public static byte[] messengerChat(String text, String postxt) {
/*  96 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/*  97 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  99 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/* 100 */     mplew.write(6);
/* 101 */     mplew.writeMapleAsciiString(text);
/* 102 */     mplew.writeMapleAsciiString(postxt);
/* 103 */     mplew.writeMapleAsciiString(text);
/* 104 */     mplew.writeMapleAsciiString(postxt);
/* 105 */     mplew.writeInt(0);
/* 106 */     mplew.writeInt(0);
/* 107 */     mplew.write(0);
/* 108 */     mplew.writeInt(0);
/* 109 */     return mplew.getPacket();
   }

   public static byte[] updateMessengerPlayer(String from, MapleCharacter chr, int position, int channel) {
/* 113 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 114 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 116 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/* 117 */     mplew.write(7);
/* 118 */     mplew.write(position);
/* 119 */     PacketHelper.addCharLook(mplew, chr, true, chr.isZeroSecondLook());




/* 124 */     return mplew.getPacket();
   }




   public static byte[] giveLoveResponse(int mode, String charname, String targetname) {
/* 131 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 132 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 134 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/* 135 */     mplew.write(10);





/* 141 */     mplew.write(mode);
/* 142 */     mplew.writeMapleAsciiString(charname);
/* 143 */     mplew.writeMapleAsciiString(targetname);

/* 145 */     return mplew.getPacket();
   }




   public static byte[] messengerPlayerInfo(MapleCharacter chr) {
/* 152 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 153 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 155 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/* 156 */     mplew.write(11);
/* 157 */     mplew.writeMapleAsciiString(chr.getName());
/* 158 */     mplew.writeInt(chr.getLevel());
/* 159 */     chr.writeJobData(mplew);
/* 160 */     mplew.writeInt(chr.getFame());
/* 161 */     mplew.writeInt(chr.getLove());
/* 162 */     if (chr.getGuildId() <= 0) {
/* 163 */       mplew.writeMapleAsciiString("-");
/* 164 */       mplew.writeMapleAsciiString("");
     } else {
/* 166 */       MapleGuild guild = WorldGuildService.getInstance().getGuild(chr.getGuildId());
/* 167 */       if (guild != null) {
/* 168 */         mplew.writeMapleAsciiString(guild.getName());
/* 169 */         if (guild.getAllianceId() > 0) {
/* 170 */           MapleGuildAlliance alliance = WorldAllianceService.getInstance().getAlliance(guild.getAllianceId());
/* 171 */           if (alliance != null) {
/* 172 */             mplew.writeMapleAsciiString(alliance.getName());
           } else {
/* 174 */             mplew.writeMapleAsciiString("");
           }
         } else {
/* 177 */           mplew.writeMapleAsciiString("");
         }
       } else {
/* 180 */         mplew.writeMapleAsciiString("-");
/* 181 */         mplew.writeMapleAsciiString("");
       }
     }
/* 184 */     mplew.write(0);

/* 186 */     return mplew.getPacket();
   }




   public static byte[] messengerWhisper(String namefrom, String chatText) {
/* 193 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 194 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 196 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/* 197 */     mplew.write(14);
/* 198 */     mplew.writeMapleAsciiString(namefrom);
/* 199 */     mplew.writeMapleAsciiString(chatText);

/* 201 */     return mplew.getPacket();
   }

   public static byte[] messengerNote(String text, int mode, int mode2) {
/* 205 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 206 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 208 */     mplew.writeShort(SendPacketOpcode.MESSENGER.getValue());
/* 209 */     mplew.write(mode);
/* 210 */     mplew.writeMapleAsciiString(text);
/* 211 */     mplew.write(mode2);

/* 213 */     return mplew.getPacket();
   }

   public static byte[] updateLove(int love) {
/* 217 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 218 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 220 */     mplew.writeShort(SendPacketOpcode.LOVE_OPERATION.getValue());
/* 221 */     mplew.write(0);
/* 222 */     mplew.writeInt(love);
/* 223 */     mplew.writeLong(DateUtil.getFileTimestamp(System.currentTimeMillis()));
/* 224 */     mplew.writeInt(3);

/* 226 */     return mplew.getPacket();
   }

   public static byte[] showLoveRank(int mode) {
/* 230 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 231 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 233 */     mplew.writeShort(SendPacketOpcode.LOVE_OPERATION.getValue());
/* 234 */     mplew.write(mode);
/* 235 */     MessengerRankingWorker rank = MessengerRankingWorker.getInstance();
/* 236 */     for (int i = 0; i < 2; i++) {
/* 237 */       MapleCharacter player = rank.getRankingPlayer(i);
/* 238 */       mplew.write((player != null) ? 1 : 0);
/* 239 */       if (player != null) {
/* 240 */         mplew.writeInt(player.getId());
/* 241 */         mplew.writeInt(player.getLove());
/* 242 */         mplew.writeLong(DateUtil.getFileTimestamp(rank.getLastUpdateTime(i)));
/* 243 */         mplew.writeMapleAsciiString(player.getName());
/* 244 */         PacketHelper.addCharLook(mplew, player, false, false);
       }
     }

/* 248 */     return mplew.getPacket();
   }
 }


/* Location:              C:\PGX\Server.jar!\tools\packet\MessengerPacket.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */